<template>
  <navbar title="账号" :left="true">
    <template #right>
      <span class="iconfont icon-lock" style="color: #fff; font-size: 22px; margin-left: 10px" @click="handleTo(1)"></span>
      <span class="iconfont icon-zhengshu_zizhi" style="color: #fff; font-size: 22px; margin-left: 10px" @click="handleTo(2)"></span>
      <van-icon name="plus" style="color: #fff; font-size: 22px; margin-left: 10px" @click="router.push({ path: '/account/search' })" />
      <van-popover  :key="1" :actions="actions" @select="onSelect" placement="bottom-end">
        <template #reference>
          <span class="iconfont icon-sandian" style="color: #fff; font-size: 22px; margin-left: 3px"></span>
        </template>
      </van-popover>
    </template>
  </navbar>
  <div class="bg"></div>
  <div class="container">
    <div class="current-info">
      <img
        class="status-img"
        src=""
      />
      <div class="logo"><img src="../../../assets/img/chat/default-user.png" /></div>
      <div class="user-name">sky</div>
      <div class="company">USA</div>
      <div class="account">123123123 - bejing</div>
      <div class="server">123123123 - bejing</div>
      <div class="money">50000 USD</div>
      <div class="info-icon">
        <van-icon name="info-o" @click="toDialog" />
      </div>
    </div>
    <div class="text">连接到</div>
    <div class="list-info">
      <img
        class="status-img"
        src=""
      />
      <div class="logo"><img src="../../../assets/img/chat/default-user.png" /></div>
      <div class="content">
        <div class="user-name">sky1111</div>
        <div class="company">USD</div>
        <div class="account">123123123 - bbbbbbb</div>
        <div class="server">123123123 - ccccccc</div>
        <div class="money">50000 USD</div>
      </div>
      <div class="info-icon">
        <van-icon name="info-o" @click="toDialog" />
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { showToast, showDialog } from 'vant'
import navbar from '@/components/navbar.vue'
import tabbar from '@/components/tabbar.vue'

// defineProps<{ msg: string }>()
const active = ref(0)
const showPopover = ref(false)

// ruoter
const router = useRouter()

const toDialog = () => {
  showDialog({
    title: '提示',
    message: 'message'
  }).then(() => {
    // on close
  })
}

// 通过 actions 属性来定义菜单选项
const actions = [{ text: '更改密码' }, { text: '清空密码' }, { text: '删除账户' }]
const onSelect = (actions) => {
  if (actions.text == '更改密码') {
    console.log('🤡 ~ actions:', actions)
    router.push({ path: '/account/password' })
  } else if (actions.text == '清空密码') {
    showToast('清空密码')
  } else {
    showToast('删除账户')
  }
}

// jump
const handleTo = (val) => {
  if (val == 1) {
    router.push({ path: '/lock' })
  } else if (val == 2) {
    showToast('证书详细')
  }
}

onMounted(() => {})
</script>

<style scoped lang="scss">
.bg {
  background-color: #dc584d;
  width: 100%;
  height: 150px;
  position: absolute;
  top: 1px;
  left: 0;
  z-index: 0;
}
.container {
  .text {
    font-size: 14px;
    color: #737373;
    margin-left: 10px;
  }
}
.container .current-info {
  width: auto;
  margin: 10px;
  background-color: #fff;
  // height: 200px;
  box-shadow: 0 1px 4px 1px #e5e5e5;
  z-index: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.container .current-info .status-img {
  position: absolute;
  right: 0;
  top: 0;
  width: 50px;
  pointer-events: none;
}

.container .current-info .logo {
  // margin-bottom: 10px;
  // height: 0.93333rem;
}

.container .current-info .logo img {
  width: 60px;
  height: 60px;
}

.container .current-info .user-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 5px;
}

.container .current-info .company {
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 5px;
  color: #1c84fa;
}

.container .current-info .account,
.container .current-info .server {
  font-size: 12px;
  margin-bottom: 5px;
  color: #737373;
}

.container .current-info .server {
  margin-bottom: 5px;
}

.container .current-info .money {
  font-size: 13px;
  font-weight: 600;
  color: red;
}

.container .list-info {
  width: 80%;
  margin: 5px auto;
  background-color: #fff;
  box-shadow: 0 1px 4px 1px #e5e5e5;
  z-index: 1;
  position: relative;
  display: flex;
  padding: 10px;
}

.container .list-info .status-img {
  position: absolute;
  right: 0;
  top: 0;
  width: 40px;
  pointer-events: none;
}

.container .list-info .logo {
  height: 40px;
  width: 40px;
  margin-right: 10px;
}

.container .list-info .logo img {
  height: 40px;
  width: 40px;
}

.container .list-info .content {
  flex: 1;
}

.container .list-info .user-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.container .list-info .company {
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 6px;
  color: #1c84fa;
}

.container .list-info .account,
.container .list-info .server {
  font-size: 12px;
  margin-bottom: 6px;
  color: #737373;
}

.container .list-info .server {
  margin-bottom: 6px;
}

.container .list-info .money {
  font-size: 14px;
  font-weight: 600;
  color: red;
}

.right-action-box {
  display: flex;
  align-items: center;
}
.info-icon {
  position: absolute;
  bottom: 10px;
  right: 10px;
  overflow: hidden;
}
</style>
